package indigo.locale 
{
	import flash.text.TextFormat;
	/**
	 * @author Patrick Pietens
	 *
	 */
	public class Data 
	{
		namespace spreadsheet = "urn:schemas-microsoft-com:office:spreadsheet";
		use namespace spreadsheet;

		private var _text:String;
		private var _fontName:String;
		private var _size:Number = 12;
		private var _color:String = "#000000";
		private var _bold:Boolean = false;
		private var _italic:Boolean = false;
		private var _underline:Boolean = false;

		public function Data( text:String, textFormat:XMLList ):void
		{
			// Set text
			this._text = text;
			
			// Set textFormat properties
			this._fontName = textFormat.@FontName || "Arial";
			this._size = textFormat.@Size || 12;
			this._color = textFormat.@Color || "#000000";
			this._bold = new Boolean( parseInt( textFormat.@Bold ) );
			this._italic = new Boolean( parseInt( textFormat.@Italic ) );
			this._underline = textFormat.@Underline.toString( ).length > 0;
		}

		
		public function get text():String
		{
			return this._text;
		}

		
		public function get fontName():String
		{
			return this._fontName;
		}

		
		public function get size():Number
		{
			return this._size;
		}

		
		public function get color():int
		{
			return parseInt( "0x" + this._color.substr( 1 ) );
		}

		
		public function get bold():Boolean
		{
			return this._bold;
		}

		
		public function get italic():Boolean
		{
			return this._italic;
		}

		
		public function get underline():Boolean
		{
			return this._underline;
		}

		
		public function get textFormat():TextFormat
		{
			return new TextFormat( this.fontName, this.size, this.color, this.bold, this.italic, this.underline );
		}

		
		/**
		 * @inheritDoc
		 * 
		 */ 
		public function toString():String
		{
			return "[Data text='" + this._text + "' fontName='" + this.fontName + "' " + "size='" + this.size + "' " + "color='" + this.color + "' bold='" + this.bold + "' italic='" + this.italic + "' underline='" + this.underline + "' textFormat='" + this.textFormat + "']";		
		}
	}
}
